#include <iostream>
#include <cmath>
#include <algorithm>
#include <unordered_map>
#include <queue>

#define x first
#define y second

using namespace std;

typedef pair<int, string> PIS;

int f(string state) { // 估价函数-->返回每个数与它目标位置的曼哈顿距离之和
    int res = 0;
    for (int i = 0; i < state.size(); ++ i) 
        if (state[i] != 'x') {
            int t = state[i] - '1';
            res += abs(i / 3 - t / 3) + abs(i % 3 - t % 3);
        }
        
    return res;
}

string bfs(string start) {
    string end = "12345678x";
    unordered_map<string, int> dist;
    unordered_map<string, pair<string, char>> pre;
    priority_queue<PIS, vector<PIS>, greater<PIS>> heap;
    
    heap.push({f(start),  start});
    dist[start] = 0;
    
    int dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};
    char op[4] = {'u', 'd', 'l', 'r'};
    
    while (heap.size()) {
        auto t = heap.top();
        heap.pop();
        
        string state = t.y;
        
        if (state == end) break; // 找到终点即退出
        
        int x, y, sz = state.size();
        for (int i = 0; i < sz; ++ i) // 寻找X的位置以便进行交换操作
            if (state[i] == 'x') {
                x = i / 3, y = i % 3; // 将字符串中的位置转换为矩阵中的位置
                break;
            }
        
        string just = state; // 备份,交换操作时会改变原先的字符串故要存下上一次字符串和操作的话,须备份
        for (int i = 0; i < 4; ++ i) { // 遍历X的上下左右(矩阵中的位置)
            int a = x + dx[i], b = y + dy[i];
            if (a < 0 || a >= 3 || b < 0 || b >= 3) continue;
            swap(state[x * 3 + y], state[a * 3 + b]); // 再转换为字符串中的位置进行交换操作
            if (!dist.count(state) || dist[state] > dist[just] + 1) {
                dist[state] = dist[just] + 1;
                pre[state] = {just, op[i]};
                heap.push({f(state) + dist[state], state});
            }
            swap(state[x * 3 + y], state[a * 3 + b]); // 恢复，以便不影响此次X的其他操作
        }
    }
    
    string res = "";
    while (end != start) {
        res += pre[end].y;
        end = pre[end].x;
    }
    
    reverse(res.begin(), res.end());
    
    return res;
}

int main() {
    string seq, s, c;
    
    while (cin >> c) {
        if (c != "x") seq += c;
        s += c;
    }
    
    int t = 0;
    for (int i = 0; i < seq.size(); ++ i)
        for (int j = i + 1; j < seq.size(); ++ j)
            if (seq[i] > seq[j]) 
                t ++ ;
                
    if (t & 1) puts("unsolvable");
    else cout << bfs(s) << endl;
    
    return 0;
}